const sqlite3 = require('sqlite3').verbose();
const db = new sqlite3.Database('./tang_poems.db');

console.log('检查数据库中的朝代信息...\n');

db.all('SELECT title, author, dynasty FROM tang_poems LIMIT 10', (err, rows) => {
  if (err) {
    console.error('查询出错:', err);
  } else {
    console.log('前10首诗的朝代信息:');
    rows.forEach((row, index) => {
      console.log(`${index + 1}. ${row.title} - ${row.author} (${row.dynasty})`);
    });
  }
  
  db.get('SELECT COUNT(*) as count FROM tang_poems', (err, row) => {
    if (err) {
      console.error('统计出错:', err);
    } else {
      console.log(`\n总共 ${row.count} 首诗`);
    }
    
    db.get('SELECT COUNT(*) as count FROM tang_poems WHERE dynasty IS NULL OR dynasty = ""', (err, row) => {
      if (err) {
        console.error('检查空朝代出错:', err);
      } else {
        console.log(`其中 ${row.count} 首诗的朝代信息为空`);
      }
      db.close();
    });
  });
}); 